﻿$.extend($.fn.validatebox.defaults.rules, {
    minLength: {
        validator: function (value, param) {
            return value.length >= param[0];
        },
        message: '长度不得小于 {0} 位'
    },
    equals: {
        validator: function (value, param) {
            return value == $(param[0]).val();
        },
        message: '两次输入内容不一致'
    },
    length: {
        validator: function (value, param) {
            var len = $.trim(value).length;
            return len >= param[0] && len <= param[1];
        },
        message: "内容长度介于{0}和{1}之间."
    },
    zip: {
        validator: function (value) {
            return /^[1-9]\d{5}$/i.test(value);
        },
        message: "邮政编码格式不正确"
    },
    tel: {
        validator: function (value) {
            return /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/i.test(value);
        },
        message: "格式不正确,请使用下面格式:010-88888888"
    },
    mobile: {
        validator: function (value) {
            return /^(13|15|18)\d{9}$/i.test(value);
        },
        message: "手机号码格式不正确(正确格式如：13845666666)"
    },
    telOrMobile: {
        validator: function (value) {
            return /^(13|15|18)\d{9}$/i.test(value) || /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/i.test(value);
        },
        message: "请填入手机或电话号码,如 13845666666 或 010-8888888"
    },
    idcard: {
        validator: function (value) {
            return /^\d{15}(\d{2}[A-Za-z0-9])?$/i.test(value);
        },
        message: "身份证号码格式不正确"
    },
    qq: {
        validator: function (value) {
            return /^[1-9]\d{4,9}$/i.test(value);
        },
        message: "QQ号码格式不正确"
    },
    chinese: {
        validator: function (value) {
            return /^[\u0391-\uFFE5]+$/i.test(value);
        },
        message: "请输入中文"
    },
    english: {
        validator: function (value) {
            return /^[A-Za-z]+$/i.test(value);
        },
        message: "请输入英文"
    },
    unnormal: {
        validator: function (value) {
            return /.+/i.test(value);
        },
        message: "输入值不能为空和包含其他非法字符"
    },
    username: {
        validator: function (value) {
            return /^[a-zA-Z][a-zA-Z0-9_]{3,15}$/i.test(value);
        },
        message: "用户名不合法(字母开头，允许4-16字节，允许字母数字下划线)"
    }
});